//
// Created by wxd on 2025/7/14.
//

#pragma once
#include "glad/glad.h"
#include <vector>
#include <memory>


class VBO {
public:
    VBO() : m_VBO(-1), m_Usage(GL_STATIC_DRAW), m_Vertices(nullptr) {}
    explicit VBO(const std::vector<float>& data);
    VBO(const std::vector<float>& data, GLenum usage);
    VBO(const std::vector<float>& data, GLenum usage, int comp, int location);
    VBO(const VBO&) = delete;
    VBO& operator=(const VBO&) = delete;
    ~VBO();

    void bind() const;
    void bindLocation(const GLuint vaoId) const;
    void unbind() const;
    void bindData() const;

    GLuint getVBO() const;
    int getComponent() const;
    int getLocation() const;
    int getVerticeCount() const;

    void destroy();

private:
    int m_Component { 0 };
    int m_Location { 0 };

    GLuint m_VBO;
    GLenum m_Usage;
    std::unique_ptr<std::vector<float>> m_Vertices;
};

